package com.clock.controller.stage;

import com.clock.common.domain.R;
import com.clock.domain.entity.NewLevel;
import com.clock.domain.entity.Tag;
import com.clock.service.NewLevelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/level")
public class NewLevelController {

    @Autowired
    private NewLevelService newLevelService;

    @PostMapping("/addNewLevel")
    public R addNewlevel(@RequestBody  NewLevel  newLevel){

        Boolean b = newLevelService.insertNewLevel(newLevel);

        log.info("测试结束");
        if (!b) {
            return R.fail("关卡已存在,也有可能是网络开小差了哦");
        }
        return R.ok("关卡添加成功");
    }




    @GetMapping("/deleteLevel")
    public R deleteLevel(@RequestParam("id") int  id){

        boolean b = newLevelService.deleteLevel(id);
        if(!b){
            return R.fail("删除失败");
        }
        return R.ok("删除成功");
    }

}
